package com.yiji.fintech.musfinance.common.service;

import com.yiji.fintech.musfinance.base.enums.ElementTypeEnum;
import com.yiji.fintech.musfinance.common.domain.SignDomain;
import com.yiji.fintech.musfinance.entity.SignInfo;
import com.yiji.fintech.musfinance.service.SignInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by ouwen@yiji.com} on 2017/9/28.
 */
@Service
public class SignUtilService {

    @Autowired
    private SignInfoService signInfoService;
    /**
     * 判断是否存在签约信息
     * @param signDomain
     * @return
     */
    public SignInfo isExsit(SignDomain signDomain){
        SignInfo signInfoParame = new SignInfo();
        signInfoParame.setElementType(signDomain.getElementType());
        signInfoParame.setAccountName(signDomain.getAccountName());
        signInfoParame.setCertNo(signDomain.getCertNo());
        if(ElementTypeEnum.THREE == signDomain.getElementType()){
            signInfoParame.setAccountNo(signDomain.getAccountNo());
        }else if(ElementTypeEnum.FOUR == signDomain.getElementType()){
            signInfoParame.setAccountNo(signDomain.getAccountNo());
            signInfoParame.setPhoneNo(signDomain.getPhoneNo());
        }
        SignInfo signInfoDb = signInfoService.query(signInfoParame);
        return signInfoDb;
    }
}
